package org.jeecg.modules;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.service.impl.SysDictServiceImpl;
import org.jeecgframework.dict.service.AutoPoiDictServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 类的作用
 *
 * @author liujiamiao
 * @email 2544296058@qq.com
 * @date 2020-10-26 9:10
 */
@Slf4j
@Service
public class AutoPoiSexService implements AutoPoiDictServiceI {

    @Autowired
    SysDictServiceImpl sysDictService;

    /**
     * 通过字典翻译字典文本
     *
     * @Author lizhou
     */
    @Override
    public String[] queryDict(String dicTable, String dicCode, String dicText) {
        List<String> dictReplaces = new ArrayList<>();
        List<DictModel> dictModels = sysDictService.queryDictItemsByCode(dicCode);
        for (DictModel t : dictModels) {
            if (t != null) {
                log.info("字典 = {} ， = {} , = {}",t.getTitle(),t.getText(),t.getValue());
//                dictReplaces.add(t.getName() + "_" + t.getCode());
            }
        }
        if (dictReplaces != null && dictReplaces.size() != 0) {
            return dictReplaces.toArray(new String[dictReplaces.size()]);
        }
        return null;
    }

}
